function CooldownFrame_SetTime(this, duration, remaining)
 if ( duration > 0 or remaining > 0 ) then
		local h, m, s;
		local cooldownText = getglobal(this:GetName().."Text");
		local cooldownTexture = getglobal(this:GetName().."Texture");

		h = getglobal("UNIT_HOUR") or "H";
		m = getglobal("UNIT_MINUTE") or "M";
		s = getglobal("UNIT_SECOND") or "S";
		
		if ( remaining >= 14400 ) then
			cooldownText:SetText(math.floor(remaining / 3600)..h);
		elseif ( remaining >= 300 ) then
			cooldownText:SetText(math.floor(remaining / 60)..m);
		elseif ( remaining >= 60 ) then
			cooldownText:SetText(math.floor(remaining));
		elseif ( remaining > 1 ) then
			cooldownText:SetText(math.floor(remaining));
		else
			cooldownText:SetText("");
		end
		
		cooldownTexture:SetCooldown(duration, remaining);
		this.starting = 1;
		this.duration = duration;
		this.remaining = remaining;
		this:Show();
	else
		this:Hide();
	end

end

function CooldownFrame_OnUpdate(this, elapsedTime)
	if ( this.starting ) then
	this.remaining = this.remaining - elapsedTime;
		if ( this.remaining > 0 ) then
		CooldownFrame_SetTime(this, this.duration, this.remaining);
		else
			this.starting = nil;
		end
	end

	if ( not this.starting ) then
		this:Hide();
	end
end